<?php
    class SyncGoldData extends APIBase {
		
		public $tag = "SyncGoldData";
		
		public function before() {
			$this->initMysql();
			$this->initCacheRedis();
			return true;
		}
		
		public function logic() {
			if (!isset($this->param['num'])) {
				$this->returnError(310, "num must be needed");
			}			
// 		file_put_contents($this->uid.'.txt','gold'.$this->param['num'].'/',FILE_APPEND);
			//下行同步后的数据
			$data['message'] = 1;
			$money = (int)$this->param['num'];
			$add_money = min($money,100000);
			$cur_money = $this->data_redis->hincrBY("hu:{$this->uid}", "money", $add_money);
			if (!empty($cur_money)){
				$data['money'] = $cur_money;
				$this->returnData($data);
			}else{
				$data['message'] = 0;
				$this->returnData($data);
			}	
		}
		
		public function after() {
			$this->deinitMysql();
			$this->deinitCacheRedis();
			$this->deinitDataRedis();
		}
    }
?>